// components/add-address/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    text: {
      type: String,
      value: '添加'
    },
    name: {
      type: String,
      value: ''
    },
    phone: {
      type: String,
      value: ''
    },
    content: {
      type: String,
      value: ''
    },
    checked: {
      type: Boolean,
      value: false
    },
    region: {
      type: String,
      value: '请选择'
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    name: '',//姓名
    phone: '',//电话号码
    region: '',
    content: '',//详情地址
    select: false,//设置默认
  },

  /**
   * 组件的方法列表
   */
  methods: {
    changeRegin: function(e) {
      let val = e.detail.value;
      console.log(this.properties.city)
      val = val.join(' - ')
      this.setData({
        region: val
      })
    },
    // 设置默认
    _changeSelect: function (e) {
      this.data.select = e.detail.value
    },
    // 向父组件传值
    _addData: function () {
      let info = {
        name: this.data.name,
        phone: this.data.phone,
        region: this.data.region,
        content: this.data.content,
        select: Number(this.data.select)
      };
      this.triggerEvent('clickSendData', info);
    },
    // 设置姓名
    _setName: function (e) {
      this.data.name = e.detail.value
    },
    // 设置手机号
    _setPhone: function (e) {
      this.data.phone = e.detail.value
    },
    // 设置详细地址
    _setContent: function (e) {
      this.data.content = e.detail.value
    }
  }
})
